package logic

import (
	"github.com/gin-gonic/gin"
	"github.com/vueadmin/app/admin/internal/dto"
	"github.com/vueadmin/app/admin/internal/model"
	"github.com/vueadmin/app/admin/internal/service"
	"github.com/vueadmin/app/admin/internal/svc"
	"github.com/vueadmin/app/admin/internal/vo"
)

type roleLogic struct{
	ctx    *gin.Context
	svcCtx *svc.ServiceContext
}

func NewRoleLogic(ctx *gin.Context, svcCtx *svc.ServiceContext) *roleLogic {
	return &roleLogic{
		ctx: ctx,
		svcCtx: svcCtx,
	}
}

/**
 * @description(数据列表)
 * @buildcode(true)
*/
func (p roleLogic) GetPageList(req *dto.RolePageReq) ([]*vo.RoleList, int64, error) {
	s := service.NewRoleService(p.svcCtx)
	return s.GetPageList(req)
}

/**
 * @description(修改排序开关)
 * @buildcode(true)
*/
func (p roleLogic) UpdateExt(req map[string]interface{}) error {
	s := service.NewRoleService(p.svcCtx)
	return s.UpdateExt(req)
}

/**
 * @description(添加)
 * @buildcode(true)
*/
func (p roleLogic) Add(req *dto.RoleAddReq) (int, error) {
	s := service.NewRoleService(p.svcCtx)
	return s.Add(req)
}

/**
 * @description(修改)
 * @buildcode(true)
*/
func (p roleLogic) Update(req *dto.RoleUpdateReq) error {
	s := service.NewRoleService(p.svcCtx)
	return s.Update(req)
}

/**
 * @description(获取修改详情)
 * @buildcode(true)
*/
func (p roleLogic) GetUpdateInfo(req *dto.RoleGetUpdateInfoReq) (*model.Role, error) {
	s := service.NewRoleService(p.svcCtx)
	return s.GetUpdateInfo(req)
}

/**
 * @description(删除)
 * @buildcode(true)
*/
func (p roleLogic) Delete(req *dto.RoleDeleteReq) error {
	s := service.NewRoleService(p.svcCtx)
	return s.Delete(req)
}

/**
 * @description(查看详情)
 * @buildcode(true)
*/
func (p roleLogic) Detail(req *dto.RoleDetailReq) (*vo.RoleDetail, error) {
	s := service.NewRoleService(p.svcCtx)
	return s.Detail(req)
}

